/*
 * Copyright (c) 2009-2011, okazoh_tk. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *  - Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 *  - Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 *  - Neither the name of the copyright holder nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef ALKES_INTERNAL_H_INCLUDED_
#define ALKES_INTERNAL_H_INCLUDED_

#if ALKES_USE_CONFIG_H
#include "alkes_config.h"
#endif


// API flags
#if defined(WIN32) && !defined(__MINGW32__)
#define ALKES_API_WIN32 (1)
#define ALKES_API_POSIX (0)

#ifndef WINVER
#define WINVER	(0x0500)
#endif

#else
#define ALKES_API_WIN32 (0)
#define ALKES_API_POSIX (1)
#endif


// Types

#if ALKES_API_WIN32
typedef __int8              int8_t;
typedef __int16             int16_t;
typedef __int32             int32_t;
typedef __int64             int64_t;
typedef unsigned __int8     uint8_t;
typedef unsigned __int16    uint16_t;
typedef unsigned __int32    uint32_t;
typedef unsigned __int64    uint64_t;
//typedef INT_PTR             intptr_t;
//typedef UINT_PTR            uintptr_t;
#else
#include <stdint.h>
#endif

#if defined(__cplusplus)

namespace alkes {

typedef uint64_t msec_type;

}

#endif

// Debug mode
#if !defined(ALKES_DEBUG)
#  if ALKES_API_WIN32
#    if defined(_DEBUG)
#      define ALKES_DEBUG
#    endif
#  elif defined(DEBUG) && (DEBUG != 0)
#    define ALKES_DEBUG
#  endif
#endif

// Export
#if ALKES_API_WIN32
#if defined(ALKES_EXPORTS)
#define AL_EXPORT   __declspec(dllexport)
#else
#define AL_EXPORT   __declspec(dllimport)
#endif
#else
#define AL_EXPORT
#endif

#if defined(__cplusplus)
#define AL_EXPORT_API   extern "C" AL_EXPORT
#else
#define AL_EXPORT_API   extern AL_EXPORT
#endif


// Operating system headers
#include "alkes/sys/windows.h"
#include "alkes/sys/posix.h"


// Decoder
#if !defined(ALKES_DECODER_PNG)
#  define ALKES_DECODER_PNG       (0)
#endif

#if !defined(ALKES_DECODER_JPEG)
#  define ALKES_DECODER_JPEG      (0)
#endif

#if !defined(ALKES_DECODER_BITMAP)
#  define ALKES_DECODER_BITMAP    (1)
#endif

// system header and api
#include <stdlib.h>
#define alkes_abort()   abort()


// debug header
#include "alkes/core/Debug.h"

#endif
